package com.umgsai.thread.thread34;

/**
 * 多生产者多消费者
 * @author Admin
 *
 */
public class Main {
	public static void main(String[] args) {
		MyStack myStack = new MyStack();
		Producer producer1 = new Producer(myStack);
		Producer producer2 = new Producer(myStack);
		Producer producer3 = new Producer(myStack);
		Producer producer4 = new Producer(myStack);
		Producer producer5 = new Producer(myStack);
		
		ThreadP threadP1 = new ThreadP(producer1);
		ThreadP threadP2 = new ThreadP(producer2);
		ThreadP threadP3 = new ThreadP(producer3);
		ThreadP threadP4 = new ThreadP(producer4);
		ThreadP threadP5 = new ThreadP(producer5);
		
		threadP1.start();
		threadP2.start();
		threadP3.start();
		threadP4.start();
		threadP5.start();
		
		Consumer consumer1 = new Consumer(myStack);
		Consumer consumer2 = new Consumer(myStack);
		Consumer consumer3 = new Consumer(myStack);
		Consumer consumer4 = new Consumer(myStack);
		Consumer consumer5 = new Consumer(myStack);
		
		ThreadC threadC1 = new ThreadC(consumer1);
		ThreadC threadC2 = new ThreadC(consumer2);
		ThreadC threadC3 = new ThreadC(consumer3);
		ThreadC threadC4 = new ThreadC(consumer4);
		ThreadC threadC5 = new ThreadC(consumer5);
		
		threadC1.start();
		threadC2.start();
		threadC3.start();
		threadC4.start();
		threadC5.start();
	}
}
